package com.khh.mapper;

import com.khh.entity.Book;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.StatementType;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * Created by webrx on 2017-08-25.
 */
public interface BookMapper {

    //多参数 对象
    @Insert("insert into book values(null,#{name},#{price},#{bdate})")
    public int insert(Book book);

    @Select("select * from book")
    public List<Book> queryall();

    //多参数map
    @Insert("insert into book values(null,#{name},#{price},null)")
    public int save(Map<String,Object> map);


    //注解多参数
    @Insert("insert into book values(null,#{n},#{p},null)")
    public int saves(@Param("n") String name, @Param("p") double price);


    //存储过程 查询所有
    @Select("call sel")  @Options(statementType = StatementType.CALLABLE)
    public List<Book> sel();


    //插入数据
    @Update("call ins(#{n},#{p},#{b})") @Options(statementType = StatementType.CALLABLE)
    public void ins(@Param("n") String name, @Param("p") int price, @Param("b") String date);


    //插入数据 有返回值
    /*@Update("call ins(#{n},#{p},#{b}") @Options(statementType = StatementType.CALLABLE)
    public int inser(@Param("n") String name, @Param("p") int price, @Param("b") String date);*/



    //分页
    @Select("select * from book limit #{start},#{size}")
    public List<Book> page(@Param("start") int start,@Param("size") int size);

    @Select("select count(*) from book")
    public int getCount();

}
